package com.caiden_micheal.dynamic.formula.service.impl;

import com.caiden_micheal.base.domain.AjxResult;
import com.caiden_micheal.base.utils.RedisUtil;
import com.caiden_micheal.dynamic.formula.mapper.DFormulaMapper;
import com.caiden_micheal.dynamic.formula.service.DFormulaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

@Service
public class DFormulaServiceImpl implements DFormulaService {
    private static final Logger logger = LoggerFactory.getLogger(DFormulaServiceImpl.class);
    @Autowired
    private DFormulaMapper dFormulaMapper;

    @Transactional
    @Override
    public AjxResult queryAll() {
        try {
            // TODO 最后应该放入Redis中存储，访问频率较高
            return AjxResult.success(dFormulaMapper.queryAll());
        } catch (Exception e) {
            logger.error(e.toString());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjxResult.unknownError("数据库操作异常");
        }
    }
}
